Skip to content

Fix empty file inputs in Symfony 4.1 #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2018
Merged

Conversation

mathieudz
Copy link
Contributor

Symfony 4.1 fails on uploaded files that are null: they must be array
or UploadedFile. UploadedFile can only be used for actual files.
Solution is to pass the uploaded file as array instead.

The array cannot be passed for actual uploaded files because Symfony
will not trust the files because they were not created by PHP core.

A better solution would be to let Symfony accept null files (see
implementation of FileBag).

Symfony 4.1 fails on uploaded files that are null: they must be array
or UploadedFile. UploadedFile can only be used for actual files.
Solution is to pass the uploaded file as array instead.

The array cannot be passed for actual uploaded files because Symfony
will not trust the files because they were not created by PHP core.

A better solution would be to let Symfony accept null files (see
implementation of FileBag).
@andig
Copy link
Contributor

andig commented Jul 30, 2018

This should fix #111

@mathieudz
Copy link
Contributor Author

Indeed, that's the error I had.
How to reproduce: add a file input to a form and submit without specifying a file. HttpKernel replaces the React file by null and Symfony will not accept it.

@andig andig merged commit e8786d1 into php-pm:master Jul 31, 2018
@andig
Copy link
Contributor

andig commented Jul 31, 2018

Much appreciated, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants